﻿#ifndef FORM_H
#define FORM_H

#include <QWidget>
#include "qcustomplot.h"
#include <QtCharts>
#include <QMouseEvent>

QT_CHARTS_USE_NAMESPACE
namespace Ui {
class Form;
}

class Form : public QWidget
{
    Q_OBJECT

public:
    explicit Form(QWidget *parent = nullptr);
    ~Form();

    QChart *m_chart;
    QCustomPlot* customPlot;

    //记录每条轴的最大值和最小值
    int MaxX = 20;
    int MaxY = 20;
    int MinX = 0;
    int MinY = 0;
    
    QVector<double> x;
    QVector<double> y;

private slots:

    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_3_clicked();

    //设置鼠标按下可移动窗口的区域，在子窗口中必须设置该区域
    void setAreaMovable(const QRect rt);

protected:
    void mousePressEvent(QMouseEvent*);
    void mouseMoveEvent(QMouseEvent*);
    void mouseReleaseEvent(QMouseEvent*);

private:
    QRect m_areaMovable;//可移动窗口的区域，鼠标只有在该区域按下才能移动窗口
    bool m_bPressed;//鼠标按下标志（不分左右键）
    QPoint m_ptPress;//鼠标按下的初始位置

private:
    Ui::Form *ui;
};

#endif // FORM_H
